package com.gdhz.xiaohengqin;

import com.gdhz.xiaohengqin.device.constants.WieGandConstant;
import com.gdhz.xiaohengqin.service.WebSocketClientService;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;

@SpringBootApplication
public class XiaoHengQinApplication {

    public static void main(String[] args) {
        ConfigurableApplicationContext context = SpringApplication.run(XiaoHengQinApplication.class, args);
        WebSocketClientService clientService = context.getBean(WebSocketClientService.class);

        // 连接到WebSocket服务器
        clientService.connect(WieGandConstant.WEBSOCKET_SERVER_URL)
                .subscribe(
                        null,
                        error -> System.err.println("Connection failed: " + error),
                        () -> System.out.println("Connection completed")
                );
    }

}
